CC=g++
CC_FLAGS=-c -g -Wall -DDTD_DEBUG -DLE_CODE_A_PIERRE

LINK=g++
LINK_FLAGS= -g

RM=rm -f

BIN_OUT=parser

INC_DIR=
LIB_DIR=
LIBS=-lboost_regex

OBJECTS=Printer.o DTDElement.o Mixte.o Name.o AttList.o Attribut.o Children.o Choice.o ContentParticules.o DTD.o Sequence.o SimpleName.o main.o
LEXS=lex.dtd.o
BISONS=dtd.tab.o

$(BIN_OUT): Makefile $(OBJECTS) $(BISONS) $(LEXS)
	$(LINK) -o $(BIN_OUT) $(OBJECTS) $(BISONS) $(LEXS) $(LIB_DIR) $(LIBS)

clean:
	$(RM)	$(BIN_OUT)
	$(RM)	$(OBJECTS) $(BISONS) $(LEXS)
	$(RM)	.*swp
	$(RM)	*.tab.h *.tab.c lex.*.c *.output *.output

$(OBJECTS):%.o: %.cpp
	$(CC) $(CC_FLAGS) $(INC_DIR) $< -o $@

$(LEXS) $(BISONS):%.o: %.c
	$(CC) $(CC_FLAGS) $(INC_DIR) $< -o $@

lex.%.c: %.l
	flex -o$@ $<

dtd.tab.c: dtd.y
	bison --debug --verbose -p dtd --defines=dtd.tab.h $< -o $@

bison_c_trop_nul: 
	make $(OBJECTS)
	$(LINK) -o $(BIN_OUT) $(OBJECTS) $(LIBS)
